package com.danco.planner.viewcontrollers;

import com.danco.planner.services.PlannerService;
import com.danco.planner.supportclasses.enumeration.IEventType;
import com.danco.planner.supportclasses.enumeration.PlannerEventType;
import com.danco.planner.view.builders.*;
import com.danco.planner.view.core.AbstractButton;
import com.danco.planner.view.core.View;

public class PlannerVC extends AbstractPlannerVC {

	public PlannerVC() {
		super();
	}
	public PlannerVC(View view) {
		super(view);
	}
	public PlannerVC(View view, String title) {
		super(view, title);
	}

	@Override
	protected void initAllOtherSubviews() {
		
		AbstractViewsBuilder builder = new ConsoleViewsBuilder();
		
		AbstractButton toLecturesBtn = builder.buildButton("To lectures", "lectures", PlannerEventType.ToLectures);
		AbstractButton toCoursesBtn = builder.buildButton("To courses", "courses", PlannerEventType.ToCourses);
		AbstractButton toSpeakersBtn = builder.buildButton("To speakers", "speakers", PlannerEventType.ToSpeakers);
		AbstractButton toStudentsBtn = builder.buildButton("To students", "students", PlannerEventType.ToStudents);
		
		toCoursesBtn.addListener(this);
		toLecturesBtn.addListener(this);
		toStudentsBtn.addListener(this);
		toSpeakersBtn.addListener(this);
		
		baseView.addSubviews(toCoursesBtn, toLecturesBtn, toSpeakersBtn, toStudentsBtn);
	}
	@Override
	protected String getMainContent() {	
		return PlannerService.getPlannerDescription();
	}
	
	@Override
	public void handleAction(Object arg0, IEventType arg1) {
		
		super.handleAction(arg0, arg1);
		
		if (arg1 == PlannerEventType.ToCourses) {
			
			CoursesVC coursesVC = new CoursesVC(new View(), "Courses\n");
			pushViewController(coursesVC);
		}
		else if (arg1 == PlannerEventType.ToLectures) {
			
			LecturesVC lecturesVC = new LecturesVC(new View(), "Lectures\n");
			pushViewController(lecturesVC);
		}
		else if (arg1 == PlannerEventType.ToSpeakers) {
			
			SpeakersVC speakersVC = new SpeakersVC(new View(), "Speakers\n");
			pushViewController(speakersVC);
		}
		else if (arg1 == PlannerEventType.ToStudents) {
			
			StudentsVC studentsVC = new StudentsVC(new View(), "Students\n");
			pushViewController(studentsVC);
		}
		
	}
}
